package us.mooresr.aircraftscheduling.client.ui;

import us.mooresr.aircraftscheduling.shared.model.User;
import us.mooresr.aircraftscheduling.shared.model.UserDetail;

import com.gwtplatform.mvp.client.PopupViewImpl;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.shared.EventBus;
import com.google.inject.Inject;

public class UserDetailROView extends PopupViewImpl implements
		UserDetailROPresenter.MyView {

	private final PopupPanel widget;
	
	@UiField
	Label nameLabel;
	
	@UiField
	Label emailLabel;
	
	@UiField
	Label address1Label;
	
	@UiField
	Label address2Label;
	
	@UiField
	Label cityLabel;
	
	@UiField
	Label stateLabel;
	
	@UiField
	Label zipLabel;
	
	@UiField
	Label homePhoneLabel;
	
	@UiField
	Label workPhoneLabel;
	
	@UiField
	Label cellPhoneLabel;
	

	public interface Binder extends UiBinder<PopupPanel, UserDetailROView> {
	}

	@Inject
	public UserDetailROView(final EventBus eventBus, final Binder binder) {
		super(eventBus);
		
		widget = binder.createAndBindUi(this);
		widget.setGlassEnabled(true);
		
	
	}

	@Override
	public Widget asWidget() {
		return widget;
	}
	
	@UiHandler("okButton")
	void onOkClicked(ClickEvent event) {
		widget.hide();
	}
	
	@Override
	public void preLoad(User user, UserDetail userDetail) {
		nameLabel.setText(user.getName());
		emailLabel.setText(userDetail.getEmail());
		address1Label.setText(userDetail.getAddress());
		address2Label.setText(userDetail.getAddress2());
		cityLabel.setText(userDetail.getCity());
		stateLabel.setText(userDetail.getState());
		zipLabel.setText(userDetail.getZip());
		homePhoneLabel.setText(userDetail.getHomePhone());
		workPhoneLabel.setText(userDetail.getWorkPhone());
		cellPhoneLabel.setText(userDetail.getCellPhone());
		
	}

	@Override
	public void clear() {
		nameLabel.setText("");
		emailLabel.setText("");
		address1Label.setText("");
		address2Label.setText("");
		cityLabel.setText("");
		stateLabel.setText("");
		zipLabel.setText("");
		homePhoneLabel.setText("");
		workPhoneLabel.setText("");
		cellPhoneLabel.setText("");
		
	}
}
